home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gnats.idb / usr / freeware / lib / gnats / mail-query.z / mail-query
Encoding:
Text File  |  1999-04-16  |  1.9 KB  |  73 lines

  1. #!/bin/sh
  2. # Program to process GNATS queries via email.
  3. # Copyright (C) 1993 Free Software Foundation, Inc.
  4. # Contributed by Jason Merrill (jason@cygnus.com).
  5. #
  6. # This file is part of GNU GNATS.
  7. #
  8. # GNU GNATS is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2, or (at your option)
  11. # any later version.
  12. #
  13. # GNU GNATS is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with GNU GNATS; see the file COPYING.  If not, write to
  20. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. GNATS_ROOT=/usr/freeware/lib/gnats/gnats-db
  23. GNATS_ADMIN=gnats-admin
  24. MAIL_AGENT="/usr/lib/sendmail -oi -t"
  25. [ -r $GNATS_ROOT/gnats-adm/config ] && . $GNATS_ROOT/gnats-adm/config
  26.  
  27. PATH=/usr/freeware/bin:${PATH}
  28. export PATH
  29.  
  30. oldIFS="$IFS"
  31. while true; do
  32.   IFS=:
  33.   read header contents
  34.   IFS="$oldIFS"
  35.   [ -z "$header" ] && break;
  36.  
  37.   contents="`echo $contents | sed 's/^  *//'`"
  38.   
  39.   [ "$header" = "From" -a -z "$to" ] && to="$contents"
  40.   [ "$header" = "Reply-To" ] && to="$contents"
  41.   [ "$header" = "Subject" ] && args="$contents"
  42. done
  43.  
  44. mail=/tmp/query$$
  45.  
  46. exec 3>&1 4>&2 > $mail 2>&1
  47.  
  48. if [ -n "$to" ]; then
  49.   echo "To: $to"
  50.   echo "Subject: query-pr output [$args]"
  51.   echo
  52.   case $args in
  53.     *query-pr*)
  54.       query-pr --restricted --state 'o|a|f|s' \
  55.     `echo $args | sed 's/^.*query-pr//'`;;
  56.     *)
  57.       query-pr --restricted --state 'o|a|f|s' $args;;
  58.   esac
  59. else
  60.   echo "To: $GNATS_ADMIN"
  61.   echo "Subject: query-pr request failed"
  62.   echo
  63.   echo "Subject line:$args"
  64.   echo "Body of message:"
  65.   cat
  66. fi
  67.  
  68. exec >&- 1>&3 2>&4
  69.  
  70. $MAIL_AGENT < $mail
  71.  
  72. [ $? -eq 0 ] && rm -f $mail
  73.